<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <button id="qd">千代</button>
  <button id="gz">公主</button>
  <img src="img/千代.jpg" alt="" title="千代吖">
  <script>
    var qd = document.getElementById('qd');
    var gz = document.getElementById('gz');
    var img = document.querySelector('img');
    qd.onclick = function () {
      img.src = 'img/千代.jpg';
      img.title = '千代啊';
    }
    gz.onclick = function () {
      img.src = 'img/公主.jpg';
      img.title = '公主吖';
    }
  </script>
</body>

</html>